import {baseUrl, request} from "@/network/request";
//插入分类信息
export function insertCategories(name, description) {
  return request({
    url: '/categories/insertCategories',
    method: 'post',
    params: {
      name,
      description
    }
  })
}

//插入分类信息
export function insertTags(name, description) {
  return request({
    url: '/tags/insertTags',
    method: 'post',
    params: {
      name,
      description
    }
  })
}

//分页获取分类信息
export function listCategories(pageNo, pageSize) {
  return request({
    url: '/categories/listCategories',
    method: 'get',
    params: {
      pageNo,
      pageSize
    }
  })
}

//分页获取标签信息
export function listTags(pageNo, pageSize) {
  return request({
    url: '/tags/listTags',
    method: 'get',
    params: {
      pageNo,
      pageSize
    }
  })
}


//获取全部分类信息
export function allCategories() {
  return request({
    url: '/categories/allCategories',
    method: 'get'
  })
}

//获取全部标签信息
export function allTags() {
  return request({
    url: '/tags/allTags',
    method: 'get'
  })
}

//更新分类信息
export function updateCategory(categoryId, name, description) {
  return request({
    url: '/categories/updateCategory',
    method: 'post',
    params: {
      categoryId,
      name,
      description
    }
  })
}
//更新标签信息
export function updateTags(id, name, description) {
  return request({
    url: '/tags/updateTags',
    method: 'post',
    params: {
      id,
      name,
      description
    }
  })
}

//查找当前分类中的文章
export function listClassificationVoByCategoryId(categoryId) {
  return request({
    url: '/article/listClassificationVoByCategoryId',
    params: {
      categoryId
    }
  })
}
//查找当前标签中的文章
export function listClassificationVoByTagsId(tagsId) {
  return request({
    url: '/article/listClassificationVoByTagsId',
    params: {
      tagsId
    }
  })
}

//移除该分类中选中文章
export function removeArticleCategory(articleId, categoryId) {
  return request({
    url: '/article/removeArticleCategory',
    method: 'post',
    params: {
      articleId,
      categoryId
    }
  })
}

//移除该标签中选中文章
export function removeArticleTags(articleId, tagsId) {
  return request({
    url: '/article-tags/removeArticleTags',
    method: 'post',
    params: {
      articleId,
      tagsId
    }
  })
}

//批量给未分类的文章增加分类和标签
export function addArticleCategoryAndTags(categoryId, tagsId, articleId) {
  return request({
    url: '/article/addArticleCategoryAndTags',
    method: 'post',
    data: {
      categoryId,
      tagsId,
      articleId
    }
  })
}

export function listArticleCategoryIsNull() {
  return request({
    url: '/article/listArticleCategoryIsNull'
  })
}

export const insertUrl = baseUrl + '/categories/insertCategoriesIncludeImages';

export const updateImage = baseUrl + '/categories/insertCategoryImages';

